package com.jiang.jetpackdemo.model

import androidx.room.Entity
import androidx.room.PrimaryKey


@Entity(tableName = "FavoritesModel")
data class FavoritesModel(
    @PrimaryKey(autoGenerate = true)
    var id: Long?,
    val title: String,
    val type: String,
    val contentUrl: String,
    val des: String,
    val imgUrl: String,
    val date: String,
    val recommendId: Int = -1
) {
    companion object {
        const val TYPE_VIDEO: String = "VIDEO"
        const val TYPE_PICTURE: String = "PICTURE"
        const val TYPE_NEWS: String = "NEWS:"
    }

    override fun equals(other: Any?): Boolean {
        other as FavoritesModel
        return if (type != other.type) {
            false
        } else {
            imgUrl == other.imgUrl
        }
    }

    override fun hashCode(): Int {
        var result = id.hashCode()
        result = 31 * result + title.hashCode()
        result = 31 * result + type.hashCode()
        result = 31 * result + contentUrl.hashCode()
        result = 31 * result + des.hashCode()
        result = 31 * result + imgUrl.hashCode()
        result = 31 * result + date.hashCode()
        return result
    }
}